﻿namespace Journey.Adapter
{
    /// <summary>
    /// 类型自动映射适配器工厂。
    /// </summary>
    public static class TypeAdapterFactory
    {
        #region Members

        /// <summary>
        /// 当前类型自动映射适配器工厂。
        /// </summary>
        static ITypeAdapterFactory _currentTypeAdapterFactory;

        #endregion

        #region Public Static Methods

        /// <summary>
        /// 设置一个类型自动映射适配器工厂。
        /// </summary>
        /// <param name="adapterFactory">类型自动映射适配器工厂。</param>
        public static void SetCurrent(ITypeAdapterFactory adapterFactory)
        {
            _currentTypeAdapterFactory = adapterFactory;
        }
        
        /// <summary>
        /// 创建类型自动映射适配器。
        /// </summary>
        /// <returns>类型自动映射适配器对象。</returns>
        public static ITypeAdapter CreateAdapter()
        {
            return _currentTypeAdapterFactory.Create();
        }

        #endregion
    }
}